package com.forezp.keyresolver;

import com.forezp.ConfigBeans;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class HostAddrKeyResolver implements KeyResolver {

    Logger logger = LoggerFactory.getLogger(ConfigBeans.class);


    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {

        final Mono<String> just = Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress());

        logger.info(just.toString());

        return just;
    }

}
